﻿using System;
using System.Collections;
using System.Collections.Generic;

namespace BotonJXC.Util
{
    public class TreeDataNode<T> : IEnumerable<TreeDataNode<T>>
    {
        private IList<TreeDataNode<T>> _childDataNodes;
        public TreeDataNode()
        {
            _childDataNodes = new List<TreeDataNode<T>>();
        }
        public TreeDataNode(T data)
        {
            _childDataNodes = new List<TreeDataNode<T>>();
            this.Data = data;
        }
        public IList<TreeDataNode<T>> Nodes { get { return _childDataNodes; } }
        public T Data { get; set; }
        public void Add(T data)
        {
            _childDataNodes.Add(new TreeDataNode<T>(data));
        }

        public void Add(TreeDataNode<T> data)
        {
            _childDataNodes.Add(data);
        }

        public IEnumerator<TreeDataNode<T>> GetEnumerator()
        {
            return _childDataNodes.GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return _childDataNodes.GetEnumerator();
        }
    }
}